package basicConcepts;

public class StringJavaEquality {

	
	public static void main(String[] args) {
		String str1 = "hello";
		String str2 = new String ("hello");
		
		if(str1==str2) 
			System.out.println("JavaEquality.main()2");
		String str3 = "hello";
		if(str1==str3) 
			System.out.println("JavaEquality.main()3");
		String str4 = new String(str1);
		if(str1==str4) 
			System.out.println("JavaEquality.main()4");
		
		String str5 = str1;
		if(str1==str5) 
			System.out.println("JavaEquality.main()5");
		
		
		if(str1.hashCode() == str2.hashCode()) System.out.println("StringJavaEquality.main() hashcode");
		if(str1.toString() == str2.toString())  System.out.println("StringJavaEquality.main() toString");
		
		if(str1.toString().equals(str2.toString())) System.out.println("StringJavaEquality.main() equals");
	}
	
}
